//
//  BillingRulesVC.m
//  YueYueSpecailCarDriver
//
//  Created by 李亚军 on 17/3/3.
//  Copyright © 2017年 黄旺鑫. All rights reserved.
//

#import "BillingRulesVC.h"
#import <MBProgressHUD_QXUtils/MBProgressHUD_QXUtils-umbrella.h>
#import <QXDriverConfiguration/QXDriverConfiguration.h>
@interface BillingRulesVC ()<UIWebViewDelegate>

@end

@implementation BillingRulesVC

- (void)viewDidLoad {
    [super viewDidLoad];

    [self configureDefaultsAttributes];
    
    [self initWebView];
}

- (void)configureDefaultsAttributes {
    
    
    
    
    self.view.backgroundColor = [UIColor whiteColor];
    
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[QXDriverConfiguration imageWithName:@"nav_icon_back_white"] style:(UIBarButtonItemStyleDone) target:self action:@selector(backAction:)];
}



- (void)initWebView {
    
    UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height - 64)];
    webView.delegate = self;
    webView.backgroundColor = [UIColor whiteColor];
    NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:self.urlString]];
    [self.view addSubview:webView];
    [webView loadRequest:request];
}

- (void)viewWillAppear:(BOOL)animated {
  
    [super viewWillAppear:animated];
    
    self.navigationController.navigationBar.hidden = NO;
}


- (void)webViewDidStartLoad:(UIWebView *)webView {
    
    
    dispatch_async(dispatch_get_main_queue(), ^{
        
        MBProgressHUD *mb = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
        mb.userInteractionEnabled = NO;
    });
    
}
- (void)webViewDidFinishLoad:(UIWebView *)webView {
    
    dispatch_async(dispatch_get_main_queue(), ^{
        [MBProgressHUD hideHUDForView:self.view animated:YES];
    });
}
- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {
    
    dispatch_async(dispatch_get_main_queue(), ^{
        
        [MBProgressHUD hideHUDForView:self.view animated:YES];
        MBProgressHUD *mb = [MBProgressHUD showWithText:@"加载失败" onView:self.view hiddenDuration:2.0];
        mb.userInteractionEnabled = NO;
    });
}

#pragma mark - backAction:
- (void)backAction:(UIBarButtonItem *)barButton {
    
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
